<template>
    <div class="nav-aside">
        <el-menu :default-active="onRoutes" class="el-menu-vertical" router :default-openeds='opentList'>
            <el-submenu v-for="item in userMenusTree" :index="item.icon" :key="item.icon">
                <template slot="title">
                    <i class="iconfont" :class="['i-'+item.icon, item.iconfont]"></i>
                    <span>{{item.name}}</span>
                    <span class="count" v-if="item.count">{{item.count}}</span>
                </template>
                <template v-for="json in item.children">
                    <el-menu-item :index="json.router">
                        <span>{{json.name}}</span>
                        <span class="count" v-if="json.count">{{json.count}}</span>
                    </el-menu-item>
                </template>
            </el-submenu>
        </el-menu>
    </div>
</template>

<script>
    import '@/assets/less/modules/asideMenu.less'
    export default {
        name: 'asideMenu',
        data() {
            return {
                opentList: ['1', '2', '3']
            }
        },
        computed: {
            onRoutes() {
                return this.$route.path
            },
            userMenusTree() {
                return [
                    {
                        icon:'1',
                        iconfont:'icon-menu_homeda',
                        name:'首页',
                        children: [
                            {
                                router:'/index',
                                name: '首页 '
                            }
                        ]
                    },{
                        icon:'2',
                        name:'项目管理',
                        iconfont:'icon-menu_functionda',
                        children: [
                            {
                                router:'/manage/list?apptype=0',
                                name: '群聊'
                            }, {
                                router:'/manage/list?apptype=1',
                                name: '视频'
                            },{
                                router:'/manage/list?apptype=2',
                                name: '红包'
                            },

                        ]
                    },{
                        icon:'3',
                        name:'配置与接口',
                        iconfont:'icon-menu_setupda',
                        children: [
                            {
                                router:'/config/api',
                                name: '配置与接口'
                            }, {
                                router:'/config/admin',
                                name: '管理员设置'
                            }, 

                        ]
                    }
                ]
            }
        },
        mounted() {
            if (this.$store.getters.userInfo.token) {
                if (this.$store.getters.userMenus && this.$store.getters.userMenus.length == 0) {
                    this.$store.dispatch('userMenus')
                }
                if (this.$store.getters.getUnProcess == null) {
                    this.$store.dispatch('getUnProcess')
                }
            }
        },
        methods: {}
    }
</script>